import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.io.IOException;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
        File f =new File("test.txt");
        if(f.exists())
        {
            System.out.println("文件存在");
        }
        else{
            System.out.println("文件不存在");

        }
        try{
            f.createNewFile();
        }
        catch (IOException e)
        {
            System.out.println("创建文件异常");
            e.printStackTrace();
        }
        File f2=new File("ex10_1/src","Main.java");
        System.out.println("文件的路径:"+f2.getAbsolutePath());
        if(f2.exists())
        {
            System.out.println("文件存在");
            System.out.println(f2.canRead());
            System.out.println(f2.canWrite());
            System.out.println(f2.canExecute());
            System.out.println(f2.getName());
            System.out.println(f2.getParent());
            System.out.println(f2.getPath());
            System.out.println(f2.length());
        }
        else
        {
            System.out.println("文件不存在");
        }

        File f3=new File("DIR");
        if (f3.mkdir())
        {
            System.out.println("目录创建成功");
        }
        else
        {
            System.out.println("目录创建不成功");
        }
        String[] filenames=f3.list();
        if (null!=filenames)
        {
            for (String item:filenames)
            {
                System.out.println(item);
            }

        }
        System.out.println("---------------------------");
        FileFilter1 filter1=new FileFilter1();
        String[] filteredFileNames=f3.list(filter1);
        if (filteredFileNames!=null)
        {
            for (String item:filteredFileNames)
            {
                System.out.println(item);
            }
        }

    }
}